package mock.action;


import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;

import mock.bo.ValidateCard;
import mock.bo.ValidateCardImp;

import com.opensymphony.xwork2.ActionSupport;

public class InsertCardAction extends ActionSupport implements SessionAware{
	
	private ValidateCard vaCard = new ValidateCardImp();
	
	private String txtCard;
	private Map<String, Object> session;

	public String getTxtCard() {
		return txtCard;
	}

	public void setTxtCard(String txtCard) {
		this.txtCard = txtCard;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	
	/**
	 * validate card
	 */
	@Override
	public String execute() throws Exception {
		if(txtCard != null){
			if(vaCard.validateCard(txtCard)){
				session.put("cardNo", txtCard);
				return "success";
			}
		}
		return "error";
		//return "test";
	}

}
